import { z } from 'zod'

export const loginScheme = z.object({
	username: z.string().min(3).max(30),
	password: z.string().min(5).max(100)
})

export type IAuthForm = z.infer<typeof loginScheme>

export const userScheme = z.object({
	id: z.number(),
	username: z.string(),

	first_name: z.string(),
	last_name: z.string(),

	is_superuser: z.boolean(),
	is_staff: z.boolean()
})

export type IUser = z.infer<typeof userScheme>

export const authResponseScheme = z.object({
	expiry: z.string(),
	token: z.string(),
	user: userScheme
})

export type IAuthResponse = z.infer<typeof authResponseScheme>

export const authWhoAmIScheme = userScheme.extend({
	permissions: z.array(z.string())
})

export type IAuthWhoAmI = z.infer<typeof authWhoAmIScheme>
